package com.myschool.server.dao.impl;

import java.util.HashSet;
import java.util.Set;

import org.springframework.stereotype.Repository;

import com.myschool.server.dao.GradeDao;
import com.myschool.server.dao.support.BaseEntityDaoHibernate;
import com.myschool.server.model.Grade;

@Repository
public class GradeDaoImpl extends BaseEntityDaoHibernate<Grade> implements
		GradeDao {

	public GradeDaoImpl() {
		super(Grade.class);

	}

	@Override
	public void addGrades(Set<Grade> grades) {
		for (Grade grade : grades) {

			save(grade);
		}

	}

	@Override
	public void addGrade(Grade grade) {
		save(grade);

	}

	@Override
	public Set<Grade> retrieveAllGradesBySchool(Long schoolId) {
		return new HashSet<Grade>(getHibernateTemplate().find(
				" from Grade grade join fetch grade.sections where grade.school.entityId = ?", schoolId));

	}

}
